﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplicationRating.DB.model;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Profile;
using System.Web.Security;
using WebApplicationRating;

namespace WebApplicationRating
{
    public partial class Login1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button_Login(object sender, EventArgs e)
        {
            try
            {
                using (imageEntities ctx = new imageEntities())
                {

                    var newLogin = LoginTB.Text;
                    var newPassword = PassTB.Text;


                    //Get the specific row from Database with this ID

                    RegisteredUser u = (from u1 in ctx.RegisteredUsers
                                        where (u1.alias == LoginTB.Text) && u1.password == PassTB.Text
                                        select u1).First();

                    tbUID.Text = Convert.ToString(u.userid);
                    if (LoginTB.Text != "")
                    {

                        //SharedItems.Field1 = tbUID.Text;
                        SharedItems.Field2 = Convert.ToInt32(tbUID.Text);
                        // Display the configuration settings
                        //aspnet2Values.Text = Convert.ToString("28");

                        //lblMessage.Text = "The current user is " + curUserAlias;
                        Response.Redirect("~/Views/About.aspx");
                    }
                    else
                    {
                        lblMessage.Text = "User Login Info Needed.";
                    }

                }
            }
            catch
            {
                lblMessage.Text = "User and Password combo Not Found";

            }

        }
    }
}